﻿package app.view.components.buttons 
{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import gs.easing.Expo;
	import gs.TweenLite;
	
	/**
	 * Базовый класс для гламурной кнопки
	 * @author firsoff maxim, snzflash.com, tel: +79222345364, skype: maxim.firsoff
	 */
	public class GlamurBtnBase extends LangBtn
	{
		// app.view.components.buttons.GlamurBtnBase
		public var animaton:Sprite;
		
		public var anim:MovieClip;
		
		public var bgdSelected:MovieClip; // есть не у всех кнопок
		
		public var text:TextField;
		
		private var _id:String;
		private var _firstAlpha:Number;
		
		public function GlamurBtnBase() 
		{
			super();
			//init();
		};
		
		override protected function init():void
		{
			super.init();
			this.buttonMode = this.useHandCursor = true;
			this.doubleClickEnabled = true;
			_firstAlpha = animaton.alpha;
			setEvents();
		}
		
		private function setEvents():void
		{
			//addEventListener(MouseEvent.CLICK, onCLick);
			addEventListener(MouseEvent.MOUSE_DOWN, onDown);
			addEventListener(MouseEvent.MOUSE_UP, onUp);
		}
		
		private function removeEvents():void
		{
			//removeEventListener(MouseEvent.CLICK, onCLick);
			removeEventListener(MouseEvent.MOUSE_DOWN, onDown);
			removeEventListener(MouseEvent.MOUSE_UP, onUp);
		}
		
		public function destroy():void
		{
			removeEvents();
		}
		
		private function onDown(e:MouseEvent):void 
		{
			////trace('555');
			TweenLite.to(animaton, 1, { alpha: 0 ,ease:Expo.easeOut,onComplete:onFinishTween} );
		}
		
		private function onFinishTween():void
		{
			TweenLite.to(animaton, 1, { alpha: _firstAlpha ,ease:Expo.easeIn} );
		}
		
		private function onUp(e:MouseEvent):void 
		{
			////trace('444');
			
		}
		
		public function get id():String { return _id; }
		
		public function set id(value:String):void 
		{
			_id = value;
		}
		
	}

}